import axiosInstance from "../index";

/**
 * 获取所有角色
 * @returns 
 */
export const getRole = async () => {
    return axiosInstance({
        url: '/getRole',
        headers: {
            'Content-Type': 'application/json'
        },
        method: 'post',
    })
}

/**
 * 获取某个用户的角色信息
 * @param {*} data 
 * @returns 
 */
export const getUserRole = async (data) => {
    return axiosInstance({
        url: '/getUserRole',
        headers: {
            'Content-Type': 'application/json'
        },
        method: 'post',
        params: data
    })
}

/**
 * 获取所有的路由信息
 * @param {*} data 
 * @returns 
 */
export const getPaths = async () => {
    return axiosInstance({
        url: '/getPaths',
        headers: {
            'Content-Type': 'application/json'
        },
        method: 'post'
    })
}

/**
 * 添加路由信息
 * @param {*} data 
 * @returns 
 */
export const addPath = async (data) => {
    return axiosInstance({
        url: '/addPath',
        headers: {
            'Content-Type': 'application/json'
        },
        method: 'post',
        data,
    })
}

export const editPath = async (data) => {
    return axiosInstance({
        url: '/editPath',
        headers: {
            'Content-Type': 'application/json'
        },
        method: 'post',
        data,
    })
}

/**
 * 删除路由信息
 * @param {*} data 
 * @returns 
 */
export const deletePath = async (data) => {
    return axiosInstance({
        url: '/deletePath',
        headers: {
            'Content-Type': 'application/json'
        },
        method: 'post',
        params: data
    })
}

/**
 * 分配权限
 * @param {*} data 
 * @returns 
 */
export const editUserRole = async (data) => {
    return axiosInstance({
        url: '/editUserRole',
        headers: {
            'Content-Type': 'application/json'
        },
        method: 'post',
        data
    })
}





